<html>
<head><meta charset="utf-8"><title>pretty printing thoughts · t-compiler/wg-nll · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/index.html">t-compiler/wg-nll</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html">pretty printing thoughts</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="135467657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135467657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135467657">(Oct 09 2018 at 13:05)</a>:</h4>
<p>I would prefer if the shorthand way that things like <code>Place</code> print - ie. <code>Place::Local(Local(0))</code> being <code>_0</code> would be on <code>Display</code> and we use the derive'd <code>Debug</code> for things. It would be super helpful in being able to identify the specific case I'm seeing if I could just print it out as the types. Particularly when first starting to contribute and you aren't familiar with how to work backwards from <code>*(*(_2.3).9)</code> or something like that. There are other types where it's much more a pain too.</p>



<a name="135467768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135467768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135467768">(Oct 09 2018 at 13:06)</a>:</h4>
<p>(in reply to some comments on pretty printing in <code>#54499 Invalid "variable does not need to be mutable"</code> topic)</p>



<a name="135467947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135467947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135467947">(Oct 09 2018 at 13:09)</a>:</h4>
<p>I am torn</p>



<a name="135467954"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135467954" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135467954">(Oct 09 2018 at 13:09)</a>:</h4>
<p>the derive(Debug) output is often ridiculously painful</p>



<a name="135467965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135467965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135467965">(Oct 09 2018 at 13:09)</a>:</h4>
<p>but I agree that the shorthands are often unnecessarily cryptic</p>



<a name="135467967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135467967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135467967">(Oct 09 2018 at 13:09)</a>:</h4>
<p>on balance I think I would prefer that we use Debug a lot more often</p>



<a name="135467975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135467975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135467975">(Oct 09 2018 at 13:09)</a>:</h4>
<p>and I want <code>:?</code> to basically <em>never</em> lose data</p>



<a name="135467979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135467979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135467979">(Oct 09 2018 at 13:09)</a>:</h4>
<p>which is not at all the case today</p>



<a name="135468027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468027">(Oct 09 2018 at 13:10)</a>:</h4>
<p>I don't like the idea of using <code>{}</code></p>



<a name="135468033"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468033" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468033">(Oct 09 2018 at 13:10)</a>:</h4>
<p>In fact, I think I don't even like that we implement Debug for things</p>



<a name="135468044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468044">(Oct 09 2018 at 13:10)</a>:</h4>
<p>mostly because there is often a need to thread down context</p>



<a name="135468050"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468050" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468050">(Oct 09 2018 at 13:10)</a>:</h4>
<p>to get a good printout</p>



<a name="135468065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468065">(Oct 09 2018 at 13:11)</a>:</h4>
<blockquote>
<p>I don't like the idea of using <code>{}</code></p>
</blockquote>
<p>specifically, I think that should be reserved for "end-user" output, as is its intention</p>



<a name="135468086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468086">(Oct 09 2018 at 13:11)</a>:</h4>
<p>I think impl'ing Debug is prob — on balance — the right thing, but it'd be nice if there was a <code>foo.debug_with(context)</code> thing we could use</p>



<a name="135468093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468093">(Oct 09 2018 at 13:11)</a>:</h4>
<p>such that you could (e.g.) do <code>place.debug_with(mir)</code> and get better output</p>



<a name="135468094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468094">(Oct 09 2018 at 13:11)</a>:</h4>
<p>Yeah. It'd be nice to find some balance where we print something concise but that's also easy to work out what it represents - particularly for new contributors. I know that I spent a lot of time when starting out just iterating on debug statements to slowly but surely work out what the type I had actually was.</p>



<a name="135468143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468143">(Oct 09 2018 at 13:12)</a>:</h4>
<p>similarly maybe we could have something like <code>debug!("{}", foo.pretty_print())</code></p>



<a name="135468152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468152">(Oct 09 2018 at 13:12)</a>:</h4>
<p>vs <code>debug!("{:?}", foo)</code>, which uses <code>derive(debug)</code> output</p>



<a name="135468161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468161">(Oct 09 2018 at 13:12)</a>:</h4>
<p><code>foo.pretty_print(cx)</code></p>



<a name="135468165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468165">(Oct 09 2018 at 13:12)</a>:</h4>
<p>hmm, maybe we should just start adding that</p>



<a name="135468166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468166">(Oct 09 2018 at 13:12)</a>:</h4>
<p>my idea would be to have a <code>PrettyPrint&lt;Context&gt;</code> trait</p>



<a name="135468172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468172">(Oct 09 2018 at 13:12)</a>:</h4>
<p>and lean on specialization</p>



<a name="135468173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468173">(Oct 09 2018 at 13:12)</a>:</h4>
<p>I don't suppose I could convince you to name the method <code>pp()</code></p>



<a name="135468182"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468182" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468182">(Oct 09 2018 at 13:13)</a>:</h4>
<p>I've become pretty anti-contraction</p>



<a name="135468183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468183">(Oct 09 2018 at 13:13)</a>:</h4>
<p>just to keep us from having to break lines all over the place for <code>tidy</code>'s sake</p>



<a name="135468196"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468196" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468196">(Oct 09 2018 at 13:13)</a>:</h4>
<p>but I could be convinced in this case to make an exception</p>



<a name="135468199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468199">(Oct 09 2018 at 13:13)</a>:</h4>
<p>That's what I tried to implement before when one of my PRs intersected with the <code>ppaux</code> code.</p>



<a name="135468220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468220">(Oct 09 2018 at 13:13)</a>:</h4>
<p>in part because typing <code>pretty_print</code> is pretty tedious</p>



<a name="135468286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468286">(Oct 09 2018 at 13:14)</a>:</h4>
<p>I'm still not sure why we couldn't leverage <code>{:#?}</code> in some way</p>



<a name="135468292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468292">(Oct 09 2018 at 13:14)</a>:</h4>
<p>instead of adding new machinery...</p>



<a name="135468356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468356">(Oct 09 2018 at 13:15)</a>:</h4>
<p>Contractions for really common things - like <code>tcx</code> - are great, but unnecessary contractions were another barrier that I remember when first starting out. By no means insurmountable, but even now if I'm diving into some code I've not touched before, it's super valuable if things have sensible names.</p>



<a name="135468376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468376">(Oct 09 2018 at 13:15)</a>:</h4>
<p>or maybe somthing controlled by a  <code>-Z</code> switch would be best; I don't <em>like</em> having to drudge through debug logs with lines that are thousands of characters long...</p>



<a name="135468410"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468410" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468410">(Oct 09 2018 at 13:16)</a>:</h4>
<blockquote>
<p>I'm still not sure why we couldn't leverage <code>{:#?}</code> in some way</p>
</blockquote>
<p>a couple of reasons</p>



<a name="135468453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468453">(Oct 09 2018 at 13:16)</a>:</h4>
<p>(1) it has a meaning and that meaning is useful</p>



<a name="135468463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468463">(Oct 09 2018 at 13:16)</a>:</h4>
<p>(2) it doesn't give context</p>



<a name="135468466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468466">(Oct 09 2018 at 13:16)</a>:</h4>
<p>(3) it's RSI-inducing to type</p>



<a name="135468471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468471">(Oct 09 2018 at 13:16)</a>:</h4>
<blockquote>
<p>my idea would be to have a PrettyPrint&lt;Context&gt; trait<br>
and lean on specialization</p>
</blockquote>
<p>I have this (very outdated and broken) <a href="https://github.com/davidtwco/rust/commit/18dd915d6ddfdecee0598d09cf0103aa5cf61eda" target="_blank" title="https://github.com/davidtwco/rust/commit/18dd915d6ddfdecee0598d09cf0103aa5cf61eda">branch</a> from a while ago that did something similar. I think it was when we were doing the region naming code and wanted to be able to inject names into regions being printed inside larger types.</p>



<a name="135468498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468498">(Oct 09 2018 at 13:16)</a>:</h4>
<p>(4) its not googleable</p>



<a name="135468500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468500">(Oct 09 2018 at 13:17)</a>:</h4>
<p>(deleted)</p>



<a name="135468501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468501">(Oct 09 2018 at 13:17)</a>:</h4>
<p>I personally would prefer to write <code>debug!("{}", foo.pp(cx))</code> and things like that</p>



<a name="135468507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468507">(Oct 09 2018 at 13:17)</a>:</h4>
<p>yes, <code>pp</code> you can search for in the rustc-docs</p>



<a name="135468511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468511">(Oct 09 2018 at 13:17)</a>:</h4>
<p>and find the <code>PrettyPrint</code> trait</p>



<a name="135468525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135468525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135468525">(Oct 09 2018 at 13:17)</a>:</h4>
<p>hmm</p>



<a name="135479633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/pretty%20printing%20thoughts/near/135479633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/pretty.20printing.20thoughts.html#135479633">(Oct 09 2018 at 15:56)</a>:</h4>
<p>I'm a fan of the general concept of returning specific types that are meant to be printed. It especially makes sense with the context idea.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>